let path = require('path')
let HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
  mode: 'production',
  entry: {
    home: './src/source.js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      }
    ]
  },
  // 实时打包
  watch: true, // 对代码监控  实时编译
  watchOptions: { // 监控的选项
    poll: 1000, // 每秒问我1000次
    aggreatementTimeout: 500, // 防抖 时间
    ignored: /node_modules/ // 不需要进行监控 哪个文件
  },
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist')
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './src/index.html',
      filename: 'index.html'
    })
  ]
}